# centos 7
FROM centos:centos7.5.1804

# 添加配置文件
# add profiles
# 复制和FastDFS相关的配置文件
ADD conf/client.conf /etc/fdfs/
ADD conf/http.conf /etc/fdfs/
ADD conf/mime.types /etc/fdfs/
ADD conf/storage.conf /etc/fdfs/
ADD conf/tracker.conf /etc/fdfs/
ADD conf/nginx.conf /etc/fdfs/
# 复制和nginx相关的配置文件
ADD fastdfs.sh /home
# 这个配置是FastDFS协同nginx所需要的配置文件
ADD conf/mod_fastdfs.conf /etc/fdfs

# 添加源文件
# add source code
ADD source/libfastcommon.zip /usr/local/src/
ADD source/fastdfs.zip /usr/local/src/
ADD source/fastdfs-nginx-module.zip /usr/local/src/
ADD source/nginx-1.15.4.zip /usr/local/src/

# Run
RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y \
  &&  yum install unzip -y  \
  &&  mkdir /home/dfs \
  &&  cd /usr/local/src/  \
  && unzip libfastcommon.zip \
  && unzip fastdfs.zip \
  && unzip fastdfs-nginx-module.zip \
  && unzip nginx-1.15.4.zip \
  &&  cd libfastcommon/   \
  &&  ./make.sh && ./make.sh install  \
  &&  cd ../  \
  &&  cd fastdfs/   \
  &&  ./make.sh && ./make.sh install  \
  &&  cd ../  \
  &&  cd nginx-1.15.4/  \
  &&  ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/   \
  &&  make && make install  \
  &&  chmod +x /home/fastdfs.sh


# export config
VOLUME /etc/fdfs

EXPOSE 22122 23000 8888 80
ENTRYPOINT ["/home/fastdfs.sh"]
